using Arrowgene.Ddon.Shared.Entity.Structure;
using System.Collections.Generic;

namespace Arrowgene.Ddon.Shared.Model
{
    public class Enemy
    {       
        public Enemy()
        {
            NamedEnemyParams = NamedParam.DEFAULT_NAMED_PARAM;
            DropsTable = new DropsTable();
        }

        public Enemy(Enemy enemy)
        {
            Id = enemy.Id;
            EnemyId = enemy.EnemyId;
            NamedEnemyParams = enemy.NamedEnemyParams;
            RaidBossId = enemy.RaidBossId;
            Scale = enemy.Scale;
            Lv = enemy.Lv;
            HmPresetNo = enemy.HmPresetNo;
            StartThinkTblNo = enemy.StartThinkTblNo;
            RepopNum = enemy.RepopNum;
            RepopCount = enemy.RepopCount;
            EnemyTargetTypesId = enemy.EnemyTargetTypesId;
            MontageFixNo = enemy.MontageFixNo;
            SetType = enemy.SetType;
            InfectionType = enemy.InfectionType;
            IsBossGauge = enemy.IsBossGauge;
            IsBossBGM = enemy.IsBossBGM;
            IsManualSet = enemy.IsManualSet;
            IsAreaBoss = enemy.IsAreaBoss;
            BloodOrbs = enemy.BloodOrbs;
            HighOrbs = enemy.HighOrbs;
            SpawnTimeStart = enemy.SpawnTimeStart;
            SpawnTimeEnd = enemy.SpawnTimeEnd;
            Experience = enemy.Experience;
            DropsTable = enemy.DropsTable;
            NotifyStrongEnemy = enemy.NotifyStrongEnemy;
            Subgroup = enemy.Subgroup;
            PPDrop = enemy.PPDrop;
        }

        public uint Id { get; set; }

        public uint EnemyId { get; set; }
        public NamedParam NamedEnemyParams { get; set; }
        public uint RaidBossId { get; set; }
        public ushort Scale { get; set; } // Scale as a percentage, 100(%) is normal
        public ushort Lv { get; set; } // Level
        public ushort HmPresetNo { get; set; }
        public byte StartThinkTblNo { get; set; } // Start Think Table Number???
        public byte RepopNum { get; set; }
        public byte RepopCount { get; set; }
        public byte EnemyTargetTypesId { get; set; }
        public byte MontageFixNo { get; set; }
        public byte SetType { get; set; }
        public byte InfectionType { get; set; }
        public bool IsBossGauge { get; set; }
        public bool IsBossBGM { get; set; }
        public bool IsManualSet { get; set; }
        public bool IsAreaBoss { get; set; }
        public uint BloodOrbs { get; set; }
        public uint HighOrbs { get; set; }
        public long SpawnTimeStart { get; set;}
        public long SpawnTimeEnd { get; set; }
        public uint Experience { get; set; }
        public DropsTable DropsTable { get; set; }
        public bool NotifyStrongEnemy { get; set; }
        public uint PPDrop { get; set; }
        public uint UINameId { get 
            {
                return NameMap.GetValueOrDefault(EnemyId);
            } 
        }
        public byte Subgroup { get; set; }

        public uint GetDroppedExperience()
        {
            return Experience * (NamedEnemyParams.Experience/100);
        }

        public uint GetDroppedPlayPoints()
        {
            return PPDrop;
        }

        public CDataStageLayoutEnemyPresetEnemyInfoClient asCDataStageLayoutEnemyPresetEnemyInfoClient()
        {
            return new CDataStageLayoutEnemyPresetEnemyInfoClient()
            {
                EnemyId = EnemyId,
                NamedEnemyParamsId = NamedEnemyParams.Id,
                RaidBossId = RaidBossId,
                Scale = Scale,
                Lv = Lv,
                HmPresetNo = HmPresetNo,
                StartThinkTblNo = StartThinkTblNo,
                RepopNum = RepopNum,
                RepopCount = RepopCount,
                EnemyTargetTypesId = EnemyTargetTypesId,
                MontageFixNo = MontageFixNo,
                SetType = SetType,
                InfectionType = InfectionType,
                IsBossGauge = IsBossGauge,
                IsBossBGM = IsBossBGM,
                IsManualSet = IsManualSet,
                IsAreaBoss = IsAreaBoss,
                IsBloodEnemy = BloodOrbs > 0,
                IsHighOrbEnemy = HighOrbs > 0,
            };
        }

        /// <summary>
        /// Maps enemyId to the index used by the UI to fetch the enemy's name. 
        /// </summary>
        public static readonly Dictionary<uint, uint> NameMap = new Dictionary<uint, uint>()
        {
            {0x010100,0},
            {0x010101,1},
            {0x010102,2},
            {0x010103,3},
            {0x010104,4},
            {0x010105,3},
            {0x010110,5},
            {0x010111,6},
            {0x010112,7},
            {0x010113,8},
            {0x010114,7},
            {0x010120,295},
            {0x010121,296},
            {0x010123,297},
            {0x010124,347},
            {0x010130,298},
            {0x010131,298},
            {0x010140,299},
            {0x010141,300},
            {0x010150,177},
            {0x010151,271},
            {0x010152,272},
            {0x010153,273},
            {0x010155,178},
            {0x010160,179},
            {0x010161,261},
            {0x010162,262},
            {0x010170,274},
            {0x010171,274},
            {0x010172,274},
            {0x010180,0},
            {0x010190,275},
            {0x010191,276},
            {0x010192,277},
            {0x010195,278},
            {0x010200,32},
            {0x010201,31},
            {0x010202,301},
            {0x010203,180},
            {0x010205,30},
            {0x010206,29},
            {0x010207,28},
            {0x010208,27},
            {0x010209,181},
            {0x010210,182},
            {0x010211,183},
            {0x010212,302},
            {0x010220,184},
            {0x010221,303},
            {0x010230,304},
            {0x010240,377},
            {0x010300,40},
            {0x010301,39},
            {0x010302,38},
            {0x010303,305},
            {0x010306,154},
            {0x010307,185},
            {0x010308,37},
            {0x010309,36},
            {0x010310,35},
            {0x010311,34},
            {0x010312,33},
            {0x010313,115},
            {0x010314,186},
            {0x010315,187},
            {0x010316,188},
            {0x010317,189},
            {0x010318,190},
            {0x010320,191},
            {0x010321,192},
            {0x010322,193},
            {0x010323,194},
            {0x010324,195},
            {0x010400,46},
            {0x010401,45},
            {0x010410,44},
            {0x010411,43},
            {0x010420,306},
            {0x010421,307},
            {0x010430,260},
            {0x010431,289},
            {0x010440,348},
            {0x010450,42},
            {0x010451,171},
            {0x010460,41},
            {0x010461,196},
            {0x010470,308},
            {0x010471,309},
            {0x010480,369},
            {0x010482,370},
            {0x010500,54},
            {0x010501,54},
            {0x010502,53},
            {0x010503,52},
            {0x010504,51},
            {0x010508,198},
            {0x010509,50},
            {0x010510,49},
            {0x010511,48},
            {0x010512,47},
            {0x010513,199},
            {0x010514,200},
            {0x010515,201},
            {0x010516,202},
            {0x010517,203},
            {0x010518,204},
            {0x010519,205},
            {0x010520,206},
            {0x010530,293},
            {0x010600,58},
            {0x010601,57},
            {0x010603,207},
            {0x010605,208},
            {0x010606,56},
            {0x010607,55},
            {0x010608,310},
            {0x010610,210},
            {0x010611,209},
            {0x010612,211},
            {0x010614,212},
            {0x010621,373},
            {0x010800,69},
            {0x010810,68},
            {0x010820,213},
            {0x010821,213},
            {0x010822,213},
            {0x010823,213},
            {0x010900,15},
            {0x010901,16},
            {0x010902,19},
            {0x010903,18},
            {0x010904,214},
            {0x010905,215},
            {0x010906,216},
            {0x010907,217},
            {0x010908,218},
            {0x010909,219},
            {0x010910,17},
            {0x010911,280},
            {0x010915,311},
            {0x010920,281},
            {0x011000,67},
            {0x011001,136},
            {0x011002,137},
            {0x011003,138},
            {0x011004,139},
            {0x011005,140},
            {0x011006,141},
            {0x011010,66},
            {0x011011,142},
            {0x011012,143},
            {0x011013,144},
            {0x011014,145},
            {0x011015,146},
            {0x011016,147},
            {0x011020,175},
            {0x011021,65},
            {0x011022,148},
            {0x011023,149},
            {0x011024,150},
            {0x011025,151},
            {0x011026,152},
            {0x011027,153},
            {0x011030,64},
            {0x011031,63},
            {0x011032,62},
            {0x011033,61},
            {0x011034,60},
            {0x011040,117},
            {0x011041,105},
            {0x011042,118},
            {0x011043,117},
            {0x011044,379},
            {0x011050,119},
            {0x011051,120},
            {0x011052,121},
            {0x011053,122},
            {0x011054,123},
            {0x011055,124},
            {0x011056,125},
            {0x011057,126},
            {0x011060,220},
            {0x011061,221},
            {0x011062,222},
            {0x011063,223},
            {0x011064,224},
            {0x011065,226},
            {0x011066,225},
            {0x011067,227},
            {0x011070,282},
            {0x011071,283},
            {0x011072,284},
            {0x011073,285},
            {0x011074,286},
            {0x011075,287},
            {0x011076,288},
            {0x011080,357},
            {0x011081,357},
            {0x011082,357},
            {0x011083,357},
            {0x011100,128},
            {0x011101,129},
            {0x011102,130},
            {0x011110,131},
            {0x011111,132},
            {0x011112,133},
            {0x011120,134},
            {0x011121,116},
            {0x011122,169},
            {0x011123,168},
            {0x011124,167},
            {0x011125,166},
            {0x011130,165},
            {0x011131,164},
            {0x011132,163},
            {0x011140,162},
            {0x011150,161},
            {0x011160,160},
            {0x011170,312},
            {0x011171,312},
            {0x011172,312},
            {0x011173,351},
            {0x011200,159},
            {0x011201,364},
            {0x011210,228},
            {0x011211,228},
            {0x011300,229},
            {0x011301,229},
            {0x011302,313},
            {0x011400,239},
            {0x011401,239},
            {0x011410,266},
            {0x011411,266},
            {0x011412,266},
            {0x011413,266},
            {0x011500,197},
            {0x015000,70},
            {0x015001,70},
            {0x015002,76},
            {0x015003,76},
            {0x015004,70},
            {0x015010,230},
            {0x015012,231},
            {0x015017,232},
            {0x015020,75},
            {0x015030,74},
            {0x015031,73},
            {0x015032,263},
            {0x015033,314},
            {0x015040,72},
            {0x015041,71},
            {0x015042,315},
            {0x015050,316},
            {0x015051,316},
            {0x015052,365},
            {0x015053,372},
            {0x015054,376},
            {0x015060,317},
            {0x015061,317},
            {0x015100,83},
            {0x015102,82},
            {0x015103,81},
            {0x015104,80},
            {0x015105,82},
            {0x015200,79},
            {0x015201,234},
            {0x015202,78},
            {0x015203,77},
            {0x015204,318},
            {0x015210,233},
            {0x015211,319},
            {0x015220,320},
            {0x015230,362},
            {0x015300,84},
            {0x015301,85},
            {0x015302,89},
            {0x015303,88},
            {0x015304,87},
            {0x015305,86},
            {0x015306,236},
            {0x015310,235},
            {0x015320,264},
            {0x015321,265},
            {0x015330,321},
            {0x015400,238},
            {0x015401,237},
            {0x015406,352},
            {0x015410,94},
            {0x015411,93},
            {0x015412,92},
            {0x015413,91},
            {0x015420,90},
            {0x015500,98},
            {0x015502,97},
            {0x015503,96},
            {0x015504,95},
            {0x015505,170},
            {0x015506,240},
            {0x015507,290},
            {0x015508,322},
            {0x015509,323},
            {0x015510,324},
            {0x015600,101},
            {0x015603,360},
            {0x015604,100},
            {0x015605,99},
            {0x015610,241},
            {0x015611,375},
            {0x015620,242},
            {0x015621,325},
            {0x015622,326},
            {0x015623,381},
            {0x015700,26},
            {0x015701,25},
            {0x015706,243},
            {0x015707,24},
            {0x015708,23},
            {0x015709,22},
            {0x015710,21},
            {0x015711,20},
            {0x015712,244},
            {0x015717,245},
            {0x015718,327},
            {0x015719,371},
            {0x015720,247},
            {0x015721,269},
            {0x015723,328},
            {0x015730,329},
            {0x015740,22},
            {0x015800,14},
            {0x015801,155},
            {0x015802,156},
            {0x015810,13},
            {0x015811,157},
            {0x015812,158},
            {0x015813,246},
            {0x015814,267},
            {0x015815,268},
            {0x015820,12},
            {0x015821,330},
            {0x015822,344},
            {0x015823,345},
            {0x015824,346},
            {0x015825,359},
            {0x015826,331},
            {0x015830,11},
            {0x015831,332},
            {0x015832,332},
            {0x015833,332},
            {0x015835,366},
            {0x015836,366},
            {0x015837,366},
            {0x015838,367},
            {0x015839,333},
            {0x015840,10},
            {0x015850,9},
            {0x015851,248},
            {0x015852,380},
            {0x015860,334},
            {0x015861,335},
            {0x015862,336},
            {0x015863,337},
            {0x015870,338},
            {0x015900,249},
            {0x015910,250},
            {0x015920,270},
            {0x015921,388},
            {0x015930,339},
            {0x015932,368},
            {0x018000,114},
            {0x018200,113},
            {0x018201,112},
            {0x018300,111},
            {0x018401,110},
            {0x018600,109},
            {0x018601,108},
            {0x018602,172},
            {0x018603,108},
            {0x018604,172},
            {0x018800,107},
            {0x019000,251},
            {0x019001,251},
            {0x019100,252},
            {0x019200,253},
            {0x019201,253},
            {0x019300,254},
            {0x019301,254},
            {0x020402,106},
            {0x020403,255},
            {0x020404,350},
            {0x020500,105},
            {0x020601,256},
            {0x020602,340},
            {0x020606,349},
            {0x020700,257},
            {0x020701,257},
            {0x020702,257},
            {0x020803,341},
            {0x020804,341},
            {0x021000,104},
            {0x021001,103},
            {0x021002,102},
            {0x021003,104},
            {0x021004,342},
            {0x022000,259},
            {0x022001,259},
            {0x023000,343},
            {0x024000,378},
            {0x024001,378},
            {0x024002,378},
            {0x030100,174},
            {0x030101,173},
            {0x030104,291},
            {0x030105,292},
            {0x030112,385},
            {0x030113,385},
            {0x030114,386},
            {0x030115,385},
            {0x030116,391},
            {0x030117,394},
            {0x030118,393},
            {0x070041,75},
            {0x070042,75},
            {0x070050,230},
            {0x070051,230},
            {0x070200,96},
            {0x070210,240},
            {0x070211,240},
            {0x070410,71},
            {0x070510,74},
            {0x070520,263},
            {0x070600,84},
            {0x070610,88},
            {0x070620,264},
            {0x070640,265},
            {0x070641,265},
            {0x070700,89},
            {0x070800,79},
            {0x070810,78},
            {0x070820,234},
            {0x070830,233},
            {0x070900,26},
            {0x070910,25},
            {0x070920,23},
            {0x070930,22},
            {0x070940,24},
            {0x070950,247},
            {0x071100,103},
            {0x071101,378},
            {0x071102,378},
            {0x071250,337},
            {0x071251,334},
            {0x071252,335},
            {0x071300,106},
            {0x071310,256},
            {0x071311,340},
            {0x075120,37},
            {0x075121,37},
            {0x075130,36},
            {0x075131,36},
            {0x075300,36},
            {0x075400,343},
            {0x075401,343},
            {0x075700,101},
            {0x080000,103},
            {0x080100,102},
            {0x080200,74},
            {0x080300,106},
            {0x080400,259},
            {0x080500,294},
            {0x080501,257},
            {0x080502,257},
            {0x080503,294},
            {0x080504,374},
            {0x080505,393},
            {0x080600,269},
            {0x080700,238},
            {0x080800,362},
            {0x080801,364},
            {0x080900,340},
            {0x080901,340},
            {0x081000,378},
            {0x081001,378},
            {0x081002,378},
            {0x081003,378},
            {0x081004,391},
            {0x081005,391},
            {0x081006,391},
            {0x081007,391},
            {0x085000,14},
            {0x085001,14},
            {0x085002,14},
            {0x085003,14},
            {0x085004,12},
            {0x085010,1},
            {0x085011,1},
            {0x085012,1},
            {0x085013,1},
            {0x085014,1},
            {0x085015,1},
            {0x085016,1},
            {0x085017,1},
            {0x085018,1},
            {0x085019,1},
            {0x085110,70},
            {0x085111,70},
            {0x085112,70},
            {0x085113,70},
            {0x085114,70},
            {0x095801,382},
            {0x095802,383},
            {0x095803,384},
            {0x100100,22},
            {0x100101,106},
            {0x100104,257},
            {0x100105,259},
            {0x100106,259},
        };
    }
}
